class Solution:
    def majorityElement(self, nums: list) -> int:
        length, mid_dic = len(nums) / 2, {}
        for decimal in nums:
            if decimal not in mid_dic:
                mid_dic[decimal] = 1
            else:
                mid_dic[decimal] += 1
            if mid_dic[decimal] > length:
                return decimal


a = Solution()
print(a.majorityElement([3, 2, 3]))
print(a.majorityElement([2, 2, 1, 1, 1, 2, 2]))
